package com.example.ruihuada

import android.view.KeyEvent
import com.example.ruihuada.base.BaseActivity
import com.example.ruihuada.ui.HomeModule.frament.HomeFragment
import com.example.ruihuada.ui.HomeModule.frament.ShopFragment
import com.example.ruihuada.ui.HomeModule.frament.SocialCircleFragment
import com.example.util.ToastUtils
import kotlinx.android.synthetic.main.activity_main.*

/**
 *
 *   还没有正式搭框架  只为演示
 *   试岗过了搭建 mvvm
 *   ！！！！！！！
 *
 */
class MainActivity : BaseActivity() {

    override fun getLayoutId(): Int = R.layout.activity_main
    var mExitTime: Long = 0;
    override fun initView() {
        initBottomBar()
    }

    private fun initBottomBar() {
        bottom_bar_activity_main
            .setContainer(R.id.fl_content_activity_main)
            .setTitleSize(12)
            .setIconHeight(22)
            .setIconWidth(22)
            .setTitleBeforeAndAfterColor(
                "#6E7C89"
                , "#B39361"
            )
            .addItem(
                HomeFragment::class.java
                , getString(R.string.menu_home)
                , R.mipmap.tab_home_unselect, R.mipmap.tab_home_select
            )
            .addItem(
                SocialCircleFragment::class.java
                , getString(R.string.menu_uli)
                , R.mipmap.tab_uli_unselect, R.mipmap.tab_uli_select
            )
            .addItem(
                ShopFragment::class.java
                , getString(R.string.menu_shop)
                , R.mipmap.tab_shop_unselect, R.mipmap.tab_shop_select
            )
            .addItem(
                HomeFragment::class.java
                , getString(R.string.menu_live)
                , R.mipmap.tab_live_unselect, R.mipmap.tab_live_select
            ).addItem(
                HomeFragment::class.java
                , getString(R.string.menu_mine)
                , R.mipmap.tab_mine_unselect, R.mipmap.tab_mine_select
            )
            .build()
        bottom_bar_activity_main.setClickListen {

        }

    }

    override fun isActionBar(): Boolean = false


    override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            if (System.currentTimeMillis() - mExitTime > 2000) {
                ToastUtils.show(mContext, getString(R.string.main_exit_app))
                mExitTime = System.currentTimeMillis()
            } else {
                ToastUtils.show(mContext, "连续点击两次退出")
            }
            return true
        }
        return super.onKeyDown(keyCode, event)
    }

}